home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / MyNewEditText.p < prev    next >
Encoding:
Text File  |  1996-06-01  |  17.0 KB  |  654 lines  |  [TEXT/CWIE]

  1. unit MyNewEditText;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types,Events,TextEdit,Controls,Dialogs;
  7.         
  8.     const
  9.         paste_to_big = -20;
  10.  
  11.     type
  12.         EditObject = object
  13.                 window: DialogPtr;
  14.                 view_item: integer;
  15.                 view_rect: Rect;
  16.                 vcontrol, hcontrol: ControlHandle;
  17.                 te: TEHandle;
  18.                 has_grow: boolean; { hasgrow -> leave room for grow icon }
  19.                 readonly: boolean;
  20.                 undotext: Handle;
  21.                 undostart, undoend, undoselstart, undoselend: integer;
  22.                 undoopen: boolean;
  23.                 modified: boolean;
  24.                 procedure Create (dlg: DialogPtr; item, width: integer; vscroll, hscroll, hasgrow, static: boolean);
  25.                 procedure Destroy;
  26.                 procedure Failed (oe: OSErr);
  27.                 procedure InsertText (h: Handle);
  28.                 procedure Resize;
  29.                 procedure Draw;
  30.                 procedure DoItemWhere (er: EventRecord; item: integer);
  31.                 procedure DoIdle;
  32.                 procedure DoKey (modifiers: integer; ch: integer);
  33.                 procedure DoActivateDeactivate (activate: boolean);
  34.                 procedure Click (where: Point; extend: boolean);
  35.                 procedure Adjust;
  36.                 procedure SetupActions;
  37.                 procedure Action (vertical: boolean; part: integer);
  38.                 function EditMenuEnabled: boolean;
  39.                 procedure SetEditMenuItem (item: integer);
  40.                 procedure DoEditMenu (item: integer);
  41.             end;
  42.  
  43. implementation
  44.  
  45.     uses
  46.         Script, Scrap, MyTypes, MyDialogs;
  47.  
  48.     const
  49.         inHome = 9998;
  50.         inEnd = 9999;
  51.  
  52.     function Pin (a, b, c: longint): longint;
  53.     begin
  54.         if b < a then
  55.             Pin := a
  56.         else if b > c then
  57.             Pin := c
  58.         else
  59.             Pin := b;
  60.     end;
  61.  
  62.     procedure EditObject.Failed (oe: OSErr);
  63.     begin
  64.         SysBeep(1);
  65.     end;
  66.  
  67.     procedure EditObject.Create (dlg: DialogPtr; item, width: integer; vscroll, hscroll, hasgrow, static: boolean);
  68.         var
  69.             dr, vr: Rect;
  70.             k: integer;
  71.             h: Handle;
  72.     begin
  73.         SetPort(dlg);
  74.         window := dlg;
  75.         view_item := item;
  76.         vcontrol := nil;
  77.         has_grow := hasgrow;
  78.         readonly := static;
  79.         if vscroll then begin
  80.             SetRect(dr, 0, 0, 16, 100);
  81.             vcontrol := NewControl(window, dr, '', true, 0, 0, 0, scrollBarProc, 1);
  82.         end;
  83.         hcontrol := nil;
  84.         if hscroll then begin
  85.             SetRect(dr, 0, 0, 100, 16);
  86.             hcontrol := NewControl(window, dr, '', true, 0, 0, 0, scrollBarProc, 0);
  87.         end;
  88.         GetDItemRect(dlg, view_item, dr);
  89.         view_rect := dr;
  90.         vr := dr;
  91.         dr.right := dr.left + width;
  92.         EraseRect(view_rect);
  93.         te := TENew(dr, vr);
  94.         TEAutoView(true, te);
  95.         undotext := NewHandle(0);
  96.         undostart := -1;
  97.         undoopen := false;
  98.         modified := false;
  99.         Resize;
  100.     end;
  101.  
  102.     procedure EditObject.Destroy;
  103.     begin
  104.         TEDispose(te);
  105.         if vcontrol <> nil then
  106.             DisposeControl(vcontrol);
  107.         if hcontrol <> nil then
  108.             DisposeControl(hcontrol);
  109.         DisposeHandle(undotext);
  110.         dispose(self);
  111.     end;
  112.  
  113.     procedure EditObject.InsertText (h: Handle);
  114.         var
  115.             state: SignedByte;
  116.     begin
  117.         state := HGetState(h);
  118.         HLock(h);
  119.         TEInsert(h^, GetHandleSize(h), te);
  120.         Adjust;
  121.         HSetState(h, state);
  122.     end;
  123.  
  124.     procedure AdjustTE (te: TEHandle; hc, vc: integer);
  125. {Scroll the TERec around to match up to the potentially updated scrollbar}
  126. {values. This is really useful when the window resizes such that the}
  127. {scrollbars become inactive and the TERec had been previously scrolled.}
  128.         var
  129.             value: INTEGER;
  130.     begin
  131.         with te^^ do
  132.             TEScroll((viewRect.left - destRect.left) - hc, (viewRect.top - destRect.top) - (vc * lineHeight), te);
  133.     end; {AdjustTE}
  134.  
  135.     function AdjustHV (isVert: BOOLEAN; control: ControlHandle; te: TEHandle; canRedraw: BOOLEAN): integer;
  136. {Calculate the new control maximum value and current value, whether it is the horizontal or}
  137. {vertical scrollbar. The vertical max is calculated by comparing the number of lines to the}
  138. {vertical size of the viewRect. The horizontal max is calculated by comparing the maximum document}
  139. {width to the width of the viewRect. The current values are set by comparing the offset between}
  140. {the view and destination rects. If necessary and we canRedraw, have the control be re-drawn by}
  141. {calling ShowControl.}
  142.         var
  143.             value, lines, max: INTEGER;
  144.             oldValue, oldMax: INTEGER;
  145.             cliprgn: RgnHandle;
  146.             r: Rect;
  147.     begin
  148.         if control = nil then begin
  149.             value := 0;
  150.         end
  151.         else begin
  152.             oldValue := GetControlValue(control);
  153.             oldMax := GetControlMaximum(control);
  154.             with te^^ do begin
  155.                 if isVert then begin
  156.                     lines := nLines;
  157.         {since nLines isn’t right if the last character is a return, check for that case}
  158.                     if (teLength > 0) & (Ptr(ORD(hText^) + teLength - 1)^ = 13) then
  159.                         lines := lines + 1;
  160.                     max := lines - ((viewRect.bottom - viewRect.top) div lineHeight);
  161.                     if max < 0 then
  162.                         max := 0;            {check for negative values}
  163.                     value := (viewRect.top - destRect.top) div lineHeight
  164.                 end
  165.                 else begin
  166.                     max := destRect.right - destRect.left - (viewRect.right - viewRect.left);
  167.                     if max < 0 then
  168.                         max := 0;            {check for negative values}
  169.                     value := viewRect.left - destRect.left;
  170.                 end;
  171.                 value := Pin(0, value, max);
  172.             end;
  173.             SetControlMaximum(control, max);
  174.             SetControlValue(control, value);
  175.             if canRedraw and ((max <> oldMax) or (value <> oldValue)) then
  176.                 ShowControl(control);            {check to see if the control can be re-drawn}
  177.         end;
  178.         AdjustHV := value;
  179.     end; {AdjustHV}
  180.  
  181.     procedure EditObject.Adjust;
  182.         var
  183.             hc, vc: integer;
  184.     begin
  185.         vc := AdjustHV(true, vcontrol, te, false);
  186.         hc := AdjustHV(false, hcontrol, te, false);
  187.         AdjustTE(te, hc, vc);
  188.     end; {AdjustScrollValues}
  189.  
  190.     procedure EditObject.Resize;
  191.         const
  192.             invis = 0;
  193.             vis = 255;
  194.             inset = 3;
  195.         var
  196.             dr, vr: Rect;
  197.             pt: Point;
  198.             k: integer;
  199.             h: Handle;
  200.             wd, ht: integer;
  201.             hc, vc: integer;
  202.     begin
  203.         SetPort(window);
  204.         EraseRect(view_rect);
  205.         GetDItemRect(window, view_item, vr);
  206.         view_rect := vr;
  207.         InvalRect(vr);
  208.         InsetRect(vr, inset, inset);
  209.         if hcontrol <> nil then
  210.             vr.bottom := vr.bottom - 15;
  211.         if vcontrol <> nil then
  212.             vr.right := vr.right - 15;
  213.         vr.bottom := vr.top + (vr.bottom - vr.top) div te^^.lineHeight * te^^.lineHeight;
  214.  
  215.         pt := vr.topLeft;
  216.         SubPt(te^^.viewRect.topLeft, pt);
  217.         OffsetRect(te^^.destRect, pt.h, pt.v);
  218.  
  219.         te^^.viewRect := vr;
  220.  
  221.         if vcontrol <> nil then begin
  222.             vcontrol^^.contrlVis := invis;
  223.             MoveControl(vcontrol, view_rect.right - 16, view_rect.top);
  224.             ht := view_rect.bottom - view_rect.top;
  225.             if has_grow then
  226.                 ht := ht - 15;
  227.             SizeControl(vcontrol, 16, ht);
  228.             vc := AdjustHV(true, vcontrol, te, false);
  229.             vcontrol^^.contrlVis := vis;
  230.         end;
  231.         if hcontrol <> nil then begin
  232.             hcontrol^^.contrlVis := invis;
  233.             MoveControl(hcontrol, view_rect.left, view_rect.bottom - 16);
  234.             ht := view_rect.right - view_rect.left;
  235.             if has_grow or (vcontrol <> nil) then
  236.                 ht := ht - 15;
  237.             SizeControl(hcontrol, ht, 16);
  238.             hc := AdjustHV(false, hcontrol, te, false);
  239.             hcontrol^^.contrlVis := vis;
  240.         end;
  241.         AdjustTE(te, hc, vc);
  242.     end;
  243.  
  244.     procedure EditObject.Draw;
  245.         var
  246.             r: Rect;
  247.             pt: Point;
  248.             k: integer;
  249.             h: Handle;
  250.     begin
  251.         GetDItemRect(window, view_item, r);
  252.         EraseRect(r);
  253.         if vcontrol <> nil then begin
  254.             Draw1Control(vcontrol);
  255.         end;
  256.         if hcontrol <> nil then begin
  257.             Draw1Control(hcontrol);
  258.         end;
  259.         EraseRect(te^^.viewRect);
  260.         TEUpdate(te^^.viewRect, te);
  261.     end;
  262.  
  263.     var
  264.         actionTE: TEHandle;
  265.         action_vcontrol, action_hcontrol: ControlHandle;
  266.  
  267. { Common algorithm for pinning the value of a control. It returns the actual amount }
  268. { the value of the control changed. }
  269.     procedure ActionScroll (vertical: boolean; amount: integer);
  270.         var
  271.             value, newvalue, max: integer;
  272.             control: ControlHandle;
  273.     begin
  274.         if vertical then
  275.             control := action_vcontrol
  276.         else
  277.             control := action_hcontrol;
  278.         if control <> nil then begin
  279.             value := GetControlValue(control);
  280.             max := GetControlMaximum(control);
  281.             newvalue := Pin(0, longint(value) - amount, max);
  282.             SetControlValue(control, newvalue);
  283.             amount := value - newvalue;   { calculate true change }
  284.             if (amount <> 0) then begin
  285.                 if vertical then begin
  286.                     TEScroll(0, amount * actionTE^^.lineHeight, actionTE);
  287.                 end
  288.                 else begin
  289.                     TEScroll(amount, 0, actionTE);
  290.                 end;
  291.             end;
  292.         end;
  293.     end; { CommonAction  }
  294.  
  295. {$PUSH}
  296. {$D-}
  297.     function MyClickLoop: boolean;
  298.         var
  299.             where: Point;
  300.             old_clip: RgnHandle;
  301.     begin
  302.         SetPort(actionTE^^.inPort);
  303.         GetMouse(where);
  304.         old_clip := NewRgn;
  305.         GetClip(old_clip);
  306.         ClipRect(actionTE^^.inPort^.portRect); { need to be able to update the controls }
  307.         if where.v < actionTE^^.viewrect.top then begin
  308.             ActionScroll(true, (actionTE^^.viewrect.top - where.v) div actionTE^^.lineheight + 1);
  309.         end;
  310.         if where.v > actionTE^^.viewrect.bottom then begin
  311.             ActionScroll(true, -((where.v - actionTE^^.viewrect.bottom) div actionTE^^.lineheight + 1));
  312.         end;
  313.         if where.h < actionTE^^.viewrect.left then begin
  314.             ActionScroll(false, actionTE^^.viewrect.left - where.h);
  315.         end;
  316.         if where.h > actionTE^^.viewrect.right then begin
  317.             ActionScroll(false, -actionTE^^.viewrect.right - where.h);
  318.         end;
  319.         SetClip(old_clip);
  320.         DisposeRgn(old_clip);
  321.         MyClickLoop := true;
  322.     end;
  323. {$POP}
  324.  
  325.     procedure EditObject.SetupActions;
  326.     begin
  327.         actionTE := te;
  328.         action_vcontrol := vcontrol;
  329.         action_hcontrol := hcontrol;
  330.     end;
  331.  
  332.     procedure EditObject.Click (where: Point; extend: boolean);
  333.     begin
  334.         SetupActions;
  335.         SetPort(window);
  336.         TESetClickLoop(@MyClickLoop, te);
  337.         TEClick(where, extend, te);
  338.         if readonly and (te^^.selStart = te^^.selEnd) then begin  { kludge to make the carret go away }
  339.             TEDeactivate(te);
  340.             TEActivate(te);
  341.         end;
  342.     end;
  343.  
  344. { Determines how much to change the value of the vertical scrollbar by and how }
  345. { much to scroll the TE record.}
  346.     procedure ActionProc (control: ControlHandle; part: integer);
  347.         var
  348.             amount: integer;
  349.             vertical: boolean;
  350.     begin
  351.         if control <> nil then begin
  352.             if (part <> 0) then begin
  353.                 vertical := GetControlReference(control) <> 0;
  354.                 if vertical then begin
  355.                     case part of
  356.                         kInUpButtonControlPart, kInDownButtonControlPart:        { one line  }
  357.                             amount := 1;
  358.                         kInPageUpControlPart, kInPageDownControlPart:            { one page  }
  359.                             with actionTE^^, viewRect do
  360.                                 amount := (bottom - top) div lineHeight;
  361.                         inHome, inEnd: 
  362.                             amount := GetControlMaximum(control);
  363.                     end;
  364.                 end
  365.                 else begin
  366.                     case part of
  367.                         kInUpButtonControlPart, kInDownButtonControlPart:        { a few pixels }
  368.                             amount := 8;
  369.                         kInPageUpControlPart, kInPageDownControlPart:            { a page width }
  370.                             with actionTE^^.viewRect do
  371.                                 amount := (right - left);
  372.                         inHome, inEnd: 
  373.                             amount := GetControlMaximum(control);
  374.                     end;
  375.                 end;
  376.                 if ((part = kInDownButtonControlPart) or (part = kInPageDownControlPart) or (part = inEnd)) then
  377.                     amount := -amount;        { reverse direction for a downer  }
  378.                 ActionScroll(vertical, amount);
  379.             end;
  380.         end;
  381.     end; { ActionProc }
  382.  
  383.     procedure EditObject.Action (vertical: boolean; part: integer);
  384.     begin
  385.         SetupActions;
  386.         if vertical then begin
  387.             ActionProc(vcontrol, part);
  388.         end
  389.         else begin
  390.             ActionProc(hcontrol, part);
  391.         end;
  392.     end;
  393.  
  394.     procedure EditObject.DoItemWhere (er: EventRecord; item: integer);
  395.         var
  396.             control: ControlHandle;
  397.             value, part: integer;
  398.             uss, use: integer;
  399.     begin
  400.         uss := te^^.selStart;
  401.         use := te^^.selEnd;
  402.         SetPort(window);
  403.         GlobalToLocal(er.where);
  404.         part := FindControl(er.where, window, control);
  405.         if part = 0 then begin
  406.             if PtInRect(er.where, te^^.viewRect) then
  407.                 Click(er.where, BAND(er.modifiers, shiftKey) <> 0)
  408.         end
  409.         else begin
  410.             if part = kInIndicatorControlPart then begin
  411.                 value := GetControlValue(control);
  412.                 part := TrackControl(control, er.where, nil);
  413.                 if part <> 0 then begin
  414.                     value := value - GetControlValue(control);
  415.                     if value <> 0 then begin
  416.                         if control = vcontrol then begin
  417.                             TEScroll(0, value * te^^.lineHeight, te);
  418.                         end
  419.                         else begin
  420.                             TEScroll(value, 0, te);
  421.                         end;
  422.                     end;
  423.                 end;
  424.             end
  425.             else begin
  426.                 SetupActions;
  427.                 value := TrackControl(control, er.where, @ActionProc);
  428.             end;
  429.         end;
  430.         if (uss <> te^^.selStart) or (use <> te^^.selEnd) then
  431.             undoopen := false;
  432.     end;
  433.  
  434.     function EditObject.EditMenuEnabled: boolean;
  435.         var
  436.             i: integer;
  437.             offset: longint;
  438.     begin
  439.         for i := EMundo to EMselectall do
  440.             if i <> EMundo + 1 then
  441.                 SetEditMenuItem(i);
  442.         EditMenuEnabled := false;
  443.         if (te^^.selStart < te^^.selEnd) or (te^^.teLength > 0) then { Select All, Copy }
  444.             EditMenuEnabled := true;
  445.         if not readonly and ((undostart >= 0) or (GetScrap(nil, 'TEXT', offset) > 0)) then { Undo, Paste }
  446.             EditMenuEnabled := true;
  447.     end;
  448.  
  449.     procedure EditObject.SetEditMenuItem (item: integer);
  450.         procedure SetEnable (on: boolean);
  451.         begin
  452.             if on then
  453.                 EnableItem(GetMenuHandle(M_Edit), item)
  454.             else
  455.                 DisableItem(GetMenuHandle(M_Edit), item);
  456.         end;
  457.         var
  458.             offset: longint;
  459.     begin
  460.         case item of
  461.             EMundo: 
  462.                 SetEnable(undostart >= 0);
  463.             EMcut, EMclear: 
  464.                 SetEnable(not readonly and (te^^.selStart < te^^.selEnd));  { Can cut,clear iff there is a selection and its not readonly}
  465.             EMcopy: 
  466.                 SetEnable(te^^.selStart < te^^.selEnd);  { Can copy iff there is a selection }
  467.             EMpaste: 
  468.                 SetEnable(not readonly and (GetScrap(nil, 'TEXT', offset) > 0));        {Paste is enabled for app. windows}
  469.             EMselectall: 
  470.                 SetEnable(te^^.teLength > 0);  { Can select all iff there is something to select }
  471.             otherwise
  472.         end;
  473.     end;
  474.  
  475.     procedure CopyUndoSelection (h: Handle; te: TEHandle);
  476.     begin
  477.         SetHandleSize(h, te^^.selEnd - te^^.selStart);
  478.         BlockMove(Ptr(longint(te^^.hText^) + te^^.selStart), h^, te^^.selEnd - te^^.selStart);
  479.     end;
  480.  
  481.     procedure EditObject.DoEditMenu (item: integer);
  482.         var
  483.             oe: OSErr;
  484.             loe: longint;
  485.             th: Handle;
  486.             uss, use: integer;
  487.     begin
  488.         undoopen := false;
  489.         case item of
  490.             EMcopy:  begin
  491.                 TECopy(te);
  492.                 loe := ZeroScrap;
  493.                 oe := TEToScrap;
  494.             end;
  495.             EMselectall:  begin
  496.                 SetPort(window);
  497.                 TESetSelect(0, maxLongInt, te);
  498.             end;
  499.             EMcut:  begin
  500.                 CopyUndoSelection(undotext, te);
  501.                 undoselstart := te^^.selStart;
  502.                 undoselend := te^^.selEnd;
  503.                 undostart := te^^.selStart;
  504.                 undoend := undostart;
  505.                 TECut(te);
  506.                 loe := ZeroScrap;
  507.                 oe := TEToScrap;
  508.                 modified := true;
  509.             end;
  510.             EMclear:  begin
  511.                 CopyUndoSelection(undotext, te);
  512.                 undoselstart := te^^.selStart;
  513.                 undoselend := te^^.selEnd;
  514.                 undostart := te^^.selStart;
  515.                 undoend := undostart;
  516.                 TEDelete(te);
  517.                 modified := true;
  518.             end;
  519.             EMpaste:  begin
  520.                 oe := TEFromScrap;
  521.                 if TEGetScrapLength + (te^^.teLength - (te^^.selEnd - te^^.selStart)) > 32000 then begin
  522.                     Failed(paste_to_big);
  523.                 end
  524.                 else begin
  525.                     CopyUndoSelection(undotext, te);
  526.                     undoselstart := te^^.selStart;
  527.                     undoselend := te^^.selEnd;
  528.                     undostart := te^^.selStart;
  529.                     TEPaste(te);
  530.                     undoend := te^^.selEnd;
  531.                     modified := true;
  532.                 end;
  533.             end;
  534.             EMundo:  begin
  535.                 uss := undoselstart;
  536.                 use := undoselend;
  537.                 undoselstart := te^^.selStart;
  538.                 undoselend := te^^.selEnd;
  539.                 th := NewHandle(undoend - undostart);
  540.                 BlockMove(Ptr(longint(te^^.hText^) + undostart), th^, undoend - undostart); { save undo for redo }
  541.                 TESetSelect(undostart, undoend, te);
  542.                 TEDelete(te);
  543.                 HLock(undotext);
  544.                 TEInsert(undotext^, GetHandleSize(undotext), te);
  545.                 DisposeHandle(undotext);
  546.                 undotext := th;
  547.                 undoend := te^^.selEnd;
  548.                 TESetSelect(uss, use, te);
  549.             end;
  550.             otherwise
  551.         end;
  552.     end;
  553.  
  554.     procedure EditObject.DoIdle;
  555.     begin
  556.         if not readonly then
  557.             TEIdle(te);
  558.     end;
  559.  
  560.     procedure EditObject.DoKey (modifiers: integer; ch: integer);
  561.         procedure Doit;
  562.         begin
  563.             TEKey(chr(ch), te);
  564.             Adjust;
  565.         end;
  566.         var
  567.             dk: boolean;
  568.             cmd, opt, shift: boolean;
  569.             start, finish, length: longint;
  570.     begin
  571.         cmd := BAND(modifiers, cmdKey) <> 0;
  572.         opt := BAND(modifiers, optionKey) <> 0;
  573.         shift := BAND(modifiers, shiftKey) <> 0;
  574.         case ch of
  575.             homeChar: 
  576.                 Action(true, inHome);
  577.             endChar: 
  578.                 Action(true, inEnd);
  579.             pageUpChar: 
  580.                 Action(true, kInPageUpControlPart);
  581.             pageDownChar: 
  582.                 Action(true, kInPageDownControlPart);
  583.             rightArrowChar, leftArrowChar, upArrowChar, downArrowChar:  begin
  584.                 finish := te^^.selEnd;
  585.                 start := te^^.selStart;
  586.                 if cmd & opt & (ch = upArrowChar) then begin
  587.                     start := 0;
  588.                     if not shift then
  589.                         finish := 0;
  590.                     TESetSelect(start, finish, te);
  591.                 end
  592.                 else if cmd & opt & (ch = downArrowChar) then begin
  593.                     if not shift then
  594.                         start := maxLongInt;
  595.                     finish := maxLongInt;
  596.                     TESetSelect(start, finish, te);
  597.                 end
  598.                 else begin
  599.                     if shift and (ch = downArrowChar) then
  600.                         TESetSelect(finish, finish, te);
  601.                     TEKey(chr(ch), te);
  602.                     if shift then begin
  603.                         if te^^.selEnd > finish then
  604.                             finish := te^^.selEnd;
  605.                         if te^^.selStart < start then
  606.                             start := te^^.selStart;
  607.                         TESetSelect(start, finish, te);
  608.                     end;
  609.                 end;
  610.                 Adjust;
  611.             end;
  612.             helpChar: 
  613.                 Doit;
  614.             otherwise begin
  615.                 begin
  616.                     if not readonly then begin
  617.                         modified := true;
  618.                         if not undoopen then begin
  619.                             CopyUndoSelection(undotext, te);
  620.                             undoselstart := te^^.selStart;
  621.                             undoselend := te^^.selEnd;
  622.                             undostart := te^^.selStart;
  623.                         end;
  624.                         Doit;
  625.                         undoend := te^^.selEnd;
  626.                         undoopen := true;
  627.                     end
  628.                     else begin
  629.                         SysBeep(1);
  630.                     end; { if }
  631.                 end; { begin }
  632.             end; { otherwise }
  633.         end; { case }
  634.     end; { DoKey }
  635.  
  636.     procedure EditObject.DoActivateDeactivate (activate: boolean);
  637.     begin
  638.         if activate then begin
  639.             TEActivate(te);
  640.         end
  641.         else begin
  642.             TEDeactivate(te);
  643.         end;
  644.     end;
  645.  
  646. end.
  647. SetPort(te^^.inPort);
  648. clipRgn := NewRgn;
  649. GetClip(clipRgn);
  650. SetRect(r, 0, 0, 0, 0);
  651. ClipRect(r);
  652. SetCtlMax(control, max);
  653. SetClip(clipRgn);
  654. DisposeRgn(clipRgn);